/*
 * bsp_uart.h
 *
 *  Created on: 2024年5月22日
 *      Author: hm
 */

#ifndef APP_BSP_UART_H_
#define APP_BSP_UART_H_
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "driver/uart.h"
#include "esp_log.h"
#include <stdint.h>

#define EX_UART1_NUM  1
#define EX_UART2_NUM  2
#define PATTERN_CHR_NUM    (3)         /*!< Set the number of consecutive and identical characters received by receiver which defines a UART pattern*/
#define BUF_SIZE (1024)
#define RD_BUF_SIZE (BUF_SIZE)
#define CONFIG_EXAMPLE_UART_RXD 15
#define CONFIG_EXAMPLE_UART_TXD 16
#define UART_PIN_NO_CHANGE      (-1)


#pragma pack(1)
typedef enum {
    UART1_SEND_DATA,
	UART2_SEND_DATA,
} sys_event_type_t;

typedef struct {
	sys_event_type_t type;
    uint8_t* buf;
    uint16_t size;
} sys_event_t;
#pragma pack()

void usr_uart1_write_bytes(uint8_t *src, uint16_t size);
void usr_uart2_write_bytes(uint8_t *src, uint16_t size);
void bsp_uart1_init(void);
void bsp_uart2_init(void);
void start_task_uart(void);
void usr_mqtt_recv_a_msg(uint8_t* buf, uint16_t size);
void usr_mqtt_recv_b_msg(uint8_t* buf, uint16_t size);
void start_task_sys(void);

#endif /* APP_BSP_UART_H_ */
